// pages/result/result.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    success:0,
    cuowu:0,
    zongshu:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let answer =options.answer.split(",");
    console.log(answer)
    let st = wx.getStorageSync("st")
    let zongshu = st[0].length
    console.log(st)
    this.setData({
      zongshu:zongshu
    })
    for(let i=0;i<st[0].length;i++){
      console.log(this.data.success);
      console.log(this.data.cuowu);
      console.log("==============")
      if(st[0][i].answer=="A"){
        console.log(answer[i]);
        if(answer[i]=="0"){
          this.setData({
            success:this.data.success+1
          })
        }else{
          this.setData({
            cuowu: this.data.cuowu + 1
          })
        }
      }
      if (st[0][i].answer == "B") {
        if (answer[i] == "1") {
          this.setData({
            success: this.data.success + 1
          })
        } else {
          this.setData({
            cuowu: this.data.cuowu + 1
          })
        }
      }
      if (st[0][i].answer == "C") {
        if (answer[i] == "2") {
          this.setData({
            success: this.data.success + 1
          })
        } else {
          this.setData({
            cuowu: this.data.cuowu + 1
          })
        }
      }
      if (st[0][i].answer == "D") {
        if (answer[i] == "3") {
          this.setData({
            success: this.data.success + 1
          })
        } else {
          this.setData({
            cuowu: this.data.cuowu + 1
          })
        }
      }
      if (st[0][i].answer == "E") {
        if (answer[i] == "4") {
          this.setData({
            success: this.data.success + 1
          })
        } else {
          this.setData({
            cuowu: this.data.cuowu + 1
          })
        }
      }

    }
  },
  back:function(e){
    wx.reLaunch({
      url: '/pages/exam/exam',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})